package com.yuan.web.common.mail;

import java.util.HashMap;
import java.util.List;
import java.util.Properties;

import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import org.springframework.ui.velocity.VelocityEngineUtils;

import com.yuan.goods.Goods;

/**
 * 邮件定阅
 * 
 * @author Beni
 * 
 */
public class MailSubscribe {

	public static String content(List<Goods> goodses) throws Exception {
		VelocityEngine velocity = new VelocityEngine();
		HashMap model = new HashMap();
		model.put("goodses", goodses);

		Properties prop = new Properties();
		prop.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
		prop.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
		prop.setProperty(Velocity.OUTPUT_ENCODING, "UTF-8");
		prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
		velocity.init(prop);

		String str = VelocityEngineUtils.mergeTemplateIntoString(velocity, "subscribe.vm", model);

		return str;
	}
}